package com.muyu.danmo.service.impl;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.danmo.domain.DanmoPortfolioCollection;
import com.muyu.danmo.mapper.DanmoPortfolioCollectionMapper;
import com.muyu.danmo.service.IDanmoPortfolioCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 作品集收藏Service业务层处理
 * 
 * @author yangle
 * @date 2024-12-02
 */
@Service
public class DanmoPortfolioCollectionServiceImpl implements IDanmoPortfolioCollectionService
{
    @Autowired
    private DanmoPortfolioCollectionMapper danmoPortfolioCollectionMapper;

    /**
     * 查询作品集收藏
     * 
     * @param collectionId 作品集收藏主键
     * @return 作品集收藏
     */
    @Override
    public DanmoPortfolioCollection selectDanmoPortfolioCollectionByCollectionId(Long collectionId)
    {
        return danmoPortfolioCollectionMapper.selectDanmoPortfolioCollectionByCollectionId(collectionId);
    }

    /**
     * 查询作品集收藏列表
     * 
     * @param danmoPortfolioCollection 作品集收藏
     * @return 作品集收藏
     */
    @Override
    public List<DanmoPortfolioCollection> selectDanmoPortfolioCollectionList(DanmoPortfolioCollection danmoPortfolioCollection)
    {
        return danmoPortfolioCollectionMapper.selectDanmoPortfolioCollectionList(danmoPortfolioCollection);
    }

    /**
     * 新增作品集收藏
     * 
     * @param danmoPortfolioCollection 作品集收藏
     * @return 结果
     */
    @Override
    public Result insertDanmoPortfolioCollection(DanmoPortfolioCollection danmoPortfolioCollection)
    {
        try {
            danmoPortfolioCollection.setCreateTime(DateUtils.getNowDate());
            danmoPortfolioCollection.setFavoriteLabel("true");
           danmoPortfolioCollectionMapper.insertDanmoPortfolioCollection(danmoPortfolioCollection);
           return Result.success(danmoPortfolioCollection,"收藏成功");
        }catch (Exception e){
            return Result.error("收藏失败");
        }
         }

    /**
     * 修改作品集收藏
     * 
     * @param danmoPortfolioCollection 作品集收藏
     * @return 结果
     */
    @Override
    public Result updateDanmoPortfolioCollection(DanmoPortfolioCollection danmoPortfolioCollection)
    {
        try {
            danmoPortfolioCollection.setUpdateTime(DateUtils.getNowDate());
            danmoPortfolioCollectionMapper.updateDanmoPortfolioCollection(danmoPortfolioCollection);
            return Result.success(danmoPortfolioCollection,"修改成功");
        }catch (Exception e){
            return Result.error("修改失败");
        }
          }

    /**
     * 批量删除作品集收藏
     * 
     * @param collectionIds 需要删除的作品集收藏主键
     * @return 结果
     */
    @Override
    public Result deleteDanmoPortfolioCollectionByCollectionIds(Long[] collectionIds)
    {
        try {
             danmoPortfolioCollectionMapper.deleteDanmoPortfolioCollectionByCollectionIds(collectionIds);
            return Result.success(collectionIds,"删除成功");
        }catch (Exception e){
            return Result.error("删除失败");
        }
    }

    /**
     * 删除作品集收藏信息
     * 
     * @param collectionId 作品集收藏主键
     * @return 结果
     */
    @Override
    public Result deleteDanmoPortfolioCollectionByCollectionId(Long collectionId)
    {
        try {
             danmoPortfolioCollectionMapper.deleteDanmoPortfolioCollectionByCollectionId(collectionId);
            return Result.success(collectionId,"删除成功");
        }catch (Exception e){
            return Result.error("删除失败");
        }
    }
}
